import tarfile

path = 'new.tar.gz'
target_path = '.'

tar = tarfile.open(path, 'r:gz')
# 获得压缩文件中所有文件的名称
file_names = tar.getnames()
print(f'tar zip files name: {file_names}')

# 解压
tar.extractall(target_path)
print('done!')